home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / c / cmprss.exe / DECPRESS.CLS < prev    next >
Text File  |  1993-01-26  |  2KB  |  69 lines

  1. #ifndef DECOMPRESS_CLS
  2. #define DECOMPRESS_CLS
  3.  
  4. #include <fstream.h>
  5. #include "const.h"
  6. #include "type.h"
  7.  
  8. class cpifstream : public ifstream
  9.     {
  10.     public:
  11.  
  12.         cpifstream(void);
  13.         cpifstream(char *fn);
  14.         ~cpifstream();
  15.  
  16.         cpifstream& operator>> (char& c)            {getbuf(&c,sizeof(char)); return *this;};
  17.         cpifstream& operator>> (short& s)            {getbuf(&s,sizeof(short)); return *this;};
  18.         cpifstream& operator>> (int& i)            {getbuf(&i,sizeof(int)); return *this;};
  19.         cpifstream& operator>> (long& l)            {getbuf(&l,sizeof(long)); return *this;};
  20.         cpifstream& operator>> (float& f)            {getbuf(&f,sizeof(float)); return *this;};
  21.         cpifstream& operator>> (double& d)            {getbuf(&d,sizeof(double)); return *this;};
  22.         cpifstream& operator>> (long double& ld)    {getbuf(&ld,sizeof(long double)); return *this;};
  23.         cpifstream& read(signed char* s, int n)        {getbuf(s,n); return *this;};
  24.         cpifstream& read(unsigned char* s, int n)    {getbuf(s,n); return *this;};
  25.         cpifstream& operator>> (char *s);
  26.  
  27.         int get(void);
  28.         int peek(void);
  29.         int gcount(void) {int c=count; count=0; return c;};
  30.  
  31.         cpifstream& get(signed char* s, int len, char c='\n')            {getbuf2(s,len,c); return *this;};
  32.         cpifstream& get(unsigned char* s, int len, char c='\n')          {getbuf2(s,len,c); return *this;};
  33.         cpifstream& get(signed char& c)                            {c=get(); return *this;};
  34.         cpifstream& get(unsigned char& c)                            {c=get(); return *this;};
  35.         cpifstream& getline(signed char* s, int len, char c='\n')        {getbuf2(s,len,c,1); return *this;};
  36.         cpifstream& getline(unsigned char* s, int len, char c='\n')        {getbuf2(s,len,c,1); return *this;};
  37.         cpifstream& ignore(int n=1, int delim=EOF);
  38.  
  39.         void open(char *fn);
  40.         int done(void) {return all_done;};
  41.         filebuf* close(void);
  42.  
  43. // The following functions are defined so that they are NO OP's:
  44.  
  45.         cpifstream& putback(char) {return *this;};
  46.         cpifstream& seekg(long) {return *this;};
  47.         cpifstream& seekg(long, seek_dir) {return *this;};
  48.  
  49. // ---
  50.  
  51.     private:
  52.  
  53.         void init(void);
  54.         void clear(void);
  55.         void decode(void);
  56.         void getbuf(void* v, int l);
  57.         void getbuf2(char* s, int l, char delim, char ed=0);
  58.         int decompress(uchar *inbuff, uint inbuff_len, uchar *outbuff);
  59.  
  60.         uchar *inbuf;                // input buffer
  61.         uchar *outbuf;                // output buffer after compression
  62.         int idx;                    // output buffer index
  63.         int o_len;                // output buffer length
  64.         int all_done;
  65.         int count;
  66.     };
  67.  
  68. #endif
  69.